Package edu.claflin.finder.io.graph
Class SIFGraphIO
- java.lang.Object
-
- edu.claflin.finder.io.graph.SIFGraphIO
-
- All Implemented Interfaces:
GraphReader,GraphWriter
public final class SIFGraphIO extends java.lang.Object implements GraphReader, GraphWriter
A class for reading and writing graphs in the SIF format. The SIF, or Simple Interaction File, format is outlined in detail here:- Version:
- 3.1.1 February 2, 2016
- Author:
- Charles Allen Schultz II
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringdefaultRelationshipContains the String representation of the default relationship to use.
-
Constructor Summary
Constructors Constructor Description SIFGraphIO(java.lang.String defaultRelationship)Constructs the SIFGraphIO object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphparseGraph(java.io.File source, boolean undirected)Reads a graph from memory.private static booleantestFile(java.io.File file)Tests to see if a File is a valid graph file.private java.lang.StringverifyRelationship(java.lang.Object edgeData)Verifies the relationship between edges.voidwriteGraph(Graph toWrite)Writes graphs to memory.
-
-
-
Field Detail
-
defaultRelationship
private final java.lang.String defaultRelationship
Contains the String representation of the default relationship to use. The default relationship value is used when writing a graph and the graph being read does not use String objects to represent edges. Currently, String objects are being used for simplicity.
-
-
Method Detail
-
parseGraph
public Graph parseGraph(java.io.File source, boolean undirected)
Reads a graph from memory. Reads SIF Style graphs.- Specified by:
parseGraphin interfaceGraphReader- Parameters:
source- the File object representing the graph in memory.undirected- This boolean is IGNORED as SIF graphs are NOT undirected.- Returns:
-
writeGraph
public void writeGraph(Graph toWrite)
Writes graphs to memory. Writes SIF Style graphs.- Specified by:
writeGraphin interfaceGraphWriter- Parameters:
toWrite- the Graph object to write to memory.
-
testFile
private static boolean testFile(java.io.File file)
Tests to see if a File is a valid graph file. Currently only tests by checking to ensure the provided file is not a directory.- Parameters:
file- the File to test.- Returns:
- the boolean value representing if the file is valid.
-
verifyRelationship
private java.lang.String verifyRelationship(java.lang.Object edgeData)
Verifies the relationship between edges. Checks to see that the Object used in theGraphfor representing an edge is a String. If it not, the default relationship is used instead.- Parameters:
edgeData-- Returns:
-
-